// data/local/SavedGameLocalDataSource.kt
package com.hwpt.chesedemo.data.local

import com.hwpt.chesedemo.data.local.dao.SavedGameDao
import com.hwpt.chesedemo.data.local.entity.GameRecordEntity
import kotlinx.coroutines.flow.Flow

class SavedGameLocalDataSource(
    private val savedGameDao: SavedGameDao
) {

    fun getAllGames(): Flow<List<GameRecordEntity>> {
        return savedGameDao.getAllGames()
    }

    suspend fun getGameById(gameId: String): GameRecordEntity? {
        return savedGameDao.getGameById(gameId)
    }

    suspend fun saveGame(game: GameRecordEntity) {
        savedGameDao.insertGame(game)
    }

    suspend fun deleteGame(gameId: String) {
        savedGameDao.deleteGameById(gameId)
    }

}